package com.flyqiu.flow.bpmn.base;

import com.alibaba.fastjson2.JSONObject;

public class UserTaskMultiInstance implements IMultiInstance {
    private boolean isSequential = true;

    private ScriptModel instanceNumScript = null;
    private ScriptModel completeConditionScript = null;


    private UserTaskMultiInstance() {

    }


    @Override
    public ScriptModel getInstanceNumScript() {
        return instanceNumScript;
    }

    @Override
    public ScriptModel getCompleteConditionScript() {
        return completeConditionScript;
    }

    @Override
    public boolean getIsSequential() {
        return isSequential;
    }


    public static UserTaskMultiInstance create(JSONObject element) {
        JSONObject multiInstance = element.getJSONObject("multiInstance");
        if (multiInstance == null) {
            return null;
        }
        UserTaskMultiInstance result = new UserTaskMultiInstance();
        result.isSequential = multiInstance.getBooleanValue("isSequential", true);
        result.instanceNumScript = multiInstance.getObject("instanceNumScript", ScriptModel.class);
        result.completeConditionScript = multiInstance.getObject("completeConditionScript", ScriptModel.class);
        return result;
    }
}
